package pers.test.votemanage.controller.response;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

/**
 * @author 风苏流间者
 * @date 2021/8/06
 */
@Data
@Builder
@AllArgsConstructor
@Api("通用响应类")
public class CommResponse<T> {

    /**
     * 返回码
     */
    @ApiModelProperty(value = "返回码")
    private String code;

    /**
     * 返回消息
     */
    @ApiModelProperty(value = "返回信息")
    private String message;

    /**
     * 返回数据
     * @return
     */
    @ApiModelProperty(value = "返回数据")
    private  T data;

    /**
     * 返回查询类结果
     * @return
     */
    public  static CommResponse success(){
        CommResponse commResponse = CommResponse.builder().code("0000").message("success").build();
        return commResponse;
    }

    /**
     * 前端页面返回结果
     * @param data
     * @return
     */
    public CommResponse success(T data){
        CommResponse commResponse = CommResponse.builder().code("0000").message("success").data(data).build();
        return commResponse;
    }
}
